<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="../css/add.css">

<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script src="../ckeditor/sample.js" type="text/javascript"></script>
<link href="../ckeditor/sample.css" rel="stylesheet" type="text/css" />

<style>
select.inp {
	width: 150px;
}
</style>

<script type="text/javascript" src="../scripts/jquery-1.6.2.js"></script>
<script type="text/javascript" src="../scripts/add_check.js"></script>
<script type="text/javascript">
	$(function() {
		if (typeof location.search) {

			var value = location.search;
			var id = value.split('=')[1]; // 得到消息ID
			$.ajax({
				url : '../getSingleMessage',
				type : "post",
				data : "id=" + id,
				datatype : "json",
				success : function(data) {
					//alert(data);
					if(!typeof data){
						alert('获取数据失败！');
						return;
					}
					var message = data;
					$("#title").val(message.title);
					var index = message.keywords.lastIndexOf(';');
					var department = message.keywords.substring(index + 1);

					$('#keywords').val(message.keywords.substring(0, index));
					$('#de option').each(function(i) {
						if ($(this).val() == department) {
							$(this).attr('selected', 'true'); //赋值给选择框
						}
					});
					$('#category').val(message.category);
					$('#text').val(message.memo);
					$('#file_e').val(message.file);//将文件赋值隐藏表单域
					$('#id').val(message.id);

				}
			});
		} else {
			alert('参数传递错误!');
		}
	});

	//单击了保存按钮
	function click_submit() {
		var check_ = checkform(); //触发表单验证函数
		//alert(check_);
		if (check_) {
			can_submit(); //触发可上传函数
		}
		return check_;
	}
	//表单验证通过,点击上传按钮,调用此函数
	function can_submit() {

		$("#btnSubmit").attr("disabled", true); //将上传按钮失效
		$("#uploadShow").css("display", "inline"); //显示上传图片标志

	}

	//覆盖验证表单函数
	function checkform() {

		issubmit = true; //触发之前保证标志为true
		//可以不上传文件
		$(":input:not(:file)").blur(); //触发除文件元素外的所有表单元素的blur事件
		return issubmit && isexist;

	}
</script>
</head>

<body>
	<form action="../UpdateMessage" method="post"
		enctype="multipart/form-data" onsubmit="return click_submit();"
		id="form1">
		<div id="til">
			<p>
				<strong id="w_title">修改信息:</strong>
			</p>
		</div>
		<div class="cb">
			<div class="porleft">
				<p>
					<span class="regtlx"><b><font>*</font>&nbsp;消息标题:</b> </span> <input
						type="text" class="inp" id="title" name="title"
						onblur="javascript:checkText($(this).val().search(/^.{1,}$/)==-1,$(this).next('#titleTip'),$(this).nextAll('.normal'));" />
					<span id="titleTip" class="tip">填写相关标题</span> <span class="normal"><img
						src="" /> </span>
				</p>
				<p>
					<span class="regtlx"><b><font>*</font>&nbsp;关&nbsp;键&nbsp;字:</b>
					</span> <input type="text" class="inp" id="keywords" name="keywords"
						onblur="javascript:checkText($(this).val().search(/^.{1,500}$/)==-1,$(this).next('#keywordsTip'),$(this).nextAll('.normal'));" />
					<span id="keywordsTip" class="tip">相关信息,用作检索,多个关键字用;分隔</span> <span
						class="normal"><img src="" /> </span>
				</p>
				<p>
					<span class="regtlx"><b><font>*</font>&nbsp;所属学院:</b> </span> <select
						id="de" onblur="checkSelect(this);" onchange="checkSelect(this);"
						name="department">
						<option value="#">--请选择--</option>
						<option value="计算机科学与技术学院">计算机科学与技术学院</option>
						<option value="土木建筑学院">土木建筑学院</option>
						<option value="物理与电子学院">物理与电子学院</option>
						<option value="化学与化工学院">化学与化工学院</option>
						<option value="体育学院">体育学院</option>
						<option value="音乐学院">音乐学院</option>

					</select> <span class="normal" style=""><img src="" /> </span>
				</p>
				<p>
					<span class="regtlx"><b><font></font>&nbsp;文&nbsp;&nbsp;&nbsp;件:</b>
					</span> <input type="file" name="file" onchange="checkFile(this);"
						onblur="checkFile(this);" id="file" /> <span id="fileTip"
						class="tip"> 支持 .doc、.docx、.xls,.ppt,.pdf格式文件 </span> <span
						class="normal"><img src="" /> </span>
				</p>
				<p>
					<span class="regtlx"><b><font>*</font>&nbsp;说&nbsp;&nbsp;&nbsp;明:</b>
					</span> <br /> <br />
					<textarea cols="80" id="text" name="memo" rows="10"
						onblur="javascript:checkText($('#text').val().search(/^(.|\r|\n){1,500}$/)==-1,$('#textTip'),$('#textTip').next('.normal'));">
					</textarea>
					<script type="text/javascript">
						//         

						CKEDITOR.replace('text', {
							extraPlugins : 'autogrow'
						});

						//
					</script>
					<!--  
					<textArea id="memo" name="memo"
						onblur="javascript:checkText($(this).val().search(/^.{1,250}$/)==-1,
						$(this).next('#textTip'),$(this).nextAll('.normal'));"></textArea>-->
					<span id="textTip" class="tip">限500个汉字,字母或数字</span> <span
						class="normal"><img src="" /> </span>
				</p>
				<p>
					<img title="保存" src="../Images/tijiao.gif" id="btnSubmit"
						onclick="javascript:$('#form1').submit();"
						style="cursor: pointer;"> &nbsp;&nbsp;&nbsp; <img title="返回"
						src="../Images/quxiao.gif" id="btnSubmit"
						onclick="javascript:window.history.back(-1);"
						style="cursor: pointer;" />

				</p>
				<p id='uploadShow' style="display: none;">
					<img src="../Images/uploadPicture.gif" />
				</p>
			</div>
		</div>
		<input type="text" id="category" style="display: none;"
			name="category" value="" /> <input type="text" id="file_e"
			style="display: none;" name="file_e" value="" /> <input type="text"
			id="id" style="display: none;" name="id" value="" />
	</form>
</body>
</html>
